package utilities;

import android.content.Intent;
import android.os.BatteryManager;

public class BatteryLevel {
	
	private static Intent batteryIntent = null;
	
	public static void setBatteryIntent(Intent _batteryIntent){
		batteryIntent = _batteryIntent;
	}
	
	public static float getBatteryLevel(){
		int level = batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
		int scale = batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
		float batteryPct = level / (float)scale;
		return batteryPct;
	}

}
